import diocmApi from '@/api/diocmApi'
import { AxiosResponse } from 'axios'
import {Ref,ref} from 'vue'
interface SamJYResults {
  fapply_id: string
  fcutoff: string
  fdangerItem_ref: string
  fhiscode: string
  fitem_badge: string
  fitem_code: string
  fitem_id: number
  fitem_name: string
  fitem_ref: string
  fitem_unit: string
  fjy_id: string
  fjy_instr: string
  fod: string
  forder_by: number
  fpeicode: string
  fremark: string
  fresult_id: string
  fsvalue: string
  fvalue: string
  hospCode: string
}
interface CheckLisDetail {
  fage: string
  fcheck_time: string
  fcheckerName: string
  fdeptName: string
  fdoctorName: string
  fhz_bed: string
  fhz_id: string
  fhz_name: string
  fhz_tel: string
  fjy_date: string
  fjy_id: string
  fjy_instr: string
  fjy_yb_code: string
  fsex: string
  fybtypeName: string
  imageBacks: string[]
  samJYResults: SamJYResults[]
}
class CheckLisServer {
  static checkLisDetail: Ref<CheckLisDetail | null> =  ref(null)
  static isLoading = ref(true)
  static async findCheckLisDetail() {
    CheckLisServer.checkLisDetail.value = null
    const length = window.location.href.split('/').length
    const id = window.location.href.split('/')[length - 1] + '.json'
    const moduleName = window.location.href.split('/')[length - 2]
    const res: AxiosResponse<CheckLisDetail> = await diocmApi.findExamDetail(
      moduleName,
      id
    )
    CheckLisServer.checkLisDetail.value = res.data
    CheckLisServer.isLoading.value = false
    console.log(CheckLisServer.checkLisDetail.value)
  }
}

export default CheckLisServer
